﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ExpertSystem.Interfaces;

namespace ExpertSystem.Views
{
    public partial class EditRuleView : Form
    {
        public EditRuleView(IRule rule = null)
        {
            InitializeComponent();
            bindingSource1.DataSource = rule.Conjuncts;
       
        }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 1)
            {
                var con = (IConjunct)dataGridView1.Rows[e.RowIndex].DataBoundItem;
                EditVariableView editVariableView = new EditVariableView(con.Function.Variables.Where(v => v.IsConstant).ToList(),con);
                editVariableView.ShowDialog();
            }
        }
    }
}
